/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pluginGraphe;

import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import javax.swing.JComponent;

/**
 *
 * @author mazid
 */
public class VueCamembert implements IVueGraphe{
    
    @Override
    public void dessine(JComponent c, Graphics2D g, PlageCellule plage) {
        Rectangle area = c.getBounds();
        
        double total = 0.0D;
        for (int i:plage.getRows()) {
            for(int j:plage.getCols()){
                total += plage.getValeur(i, j);
            }
           
        }
        double cumValue = 0.0D;
        int startAngle = 0;

        for (int row:plage.getRows()) {
            for(int col:plage.getCols()){
                startAngle = (int) (cumValue * 360 / total);
                int arcAngle = (int) (plage.getValeur(row, col) * 360 / total);
                g.setColor(couleurs[row%10]);
                g.fillArc(area.x, area.y, area.width, area.height, 
                startAngle, arcAngle);
                cumValue += plage.getValeur(row, col);
                //cumul+=arcAngle;
            }
           
        }
    }

}
